<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/4/8
 * Time: 11:57
 */
namespace app\common\model;

use think\Model;
use traits\model\SoftDelete;

class Topic extends Model
{

    use SoftDelete;
    protected $deleteTime = 'delete_time';  //软删除字段,ThinkPHP5的软删除功能使用时间戳类型（数据表默认值为Null）
    protected $type = ['delete_time'  =>  'datetime'];  //写入和读取数据的时候都会自动处理成时间字符串Y-m-d H:i:s的格式。

    public function getLists()
    {
        $data = input('param.');    $limit = input('limit');
        $where['type'] = $data['type'];
        $data['title'] && $where['title'] = ['like',"%{$data['title']}%"];
        $list = $this->where($where)->order('appreciate desc,add_time desc')->paginate($limit)->toArray();
        $list['code'] = 0;//用于前台数据表格判断成功字段
        return $list;
    }

}